import store from '@/store'

/**
 * 检查权限
 * @param {Array} value
 * @returns {Boolean}
 */
export default function checkPermission(value) {
  if (value && value instanceof Array && value.length > 0) {
    const roleRoutes = store.getters && store.getters.roleRoutes
    const permissionRoles = value

    const hasPermission = roleRoutes.some(role_route => {
      return permissionRoles.includes(role_route)
    })
    return hasPermission
  } else {
    console.error(`need roles! Like v-permission="['admin','editor']"`)
    return false
  }
}
